<template>
  <view class="work-page">
    <view class="temperature">
      <view class="text"> 当前温度°C </view>
      <view class="input">
        <input
          inputmode="decimal"
          @focus="currentFocus = -1"
          :selection-start="0"
          :selection-end="10000"
          v-model="workMainData.real_temperature"
          placeholder="请输入当前温度"
        />
      </view>
      <view class="decimal"> 当前湿度% </view>
      <view class="input">
        <input
          inputmode="decimal"
          @focus="currentFocus = -1"
          :selection-start="0"
          :selection-end="10000"
          v-model="workMainData.real_humidity"
          placeholder="请输入当前湿度"
        />
      </view>
    </view>
    <template v-for="(grp, index) in groupWorksubData" :key="index">
      <view class="table">
        <view
          v-if="workMainData.key && !checkFlag[index]"
          :class="{ grp: workMainData.key, nkey: !workMainData.key }"
          @click="onCheck(index)"
          >#{{ index + 1 }}(点击复测)
        </view>
        <view
          v-if="workMainData.key && checkFlag[index]"
          :class="{ grp: workMainData.key, nkey: !workMainData.key }"
          @click="onCheck(index)"
          >#{{ index + 1 }}(点击还原)
        </view>
        <view v-if="!workMainData.key" :class="{ grp: workMainData.key, nkey: !workMainData.key }"
          >#{{ index + 1 }}
        </view>
        <view class="row1 flex-center">
          <view class="content" :class="{ active: grp[p[0]].no_pass }">
            <input
              placeholder="请输入"
              :inputmode="currInputMode"
              class="input"
              :disabled="!worktoolStore.deviceId.currDeviceId || users.includes(currentUser[0])"
              :value="grp[p[0]].decimal ? grp[p[0]].real_value : grp[p[0]].real_value2"
              :selection-start="0"
              :selection-end="10000"
              :focus="currentIndex == grp[p[0]].id"
              @focus="onFocus(p[0], grp)"
              @input="
                (e) => {
                  let eValue = Number(e.detail.value)
                  grp[p[0]].decimal
                    ? (grp[p[0]].real_value = eValue)
                    : (grp[p[0]].real_value2 = eValue)
                }
              "
              @blur="onBlur(grp[p[0]])"
              @confirm="onConfirm(p[0], grp)"
            />
            <view class="text">#{{ index + 1 }}-{{ grp[p[0]].position_id[1] }}</view>
          </view>
          <view v-if="checkFlag[index]">
            <input
              placeholder="请输入"
              inputmode="none"
              class="check"
              :disabled="!worktoolStore.deviceId.currDeviceId"
              :value="grp[p[0]].decimal ? grp[p[0]].check_value : grp[p[0]].check_value2"
              :selection-start="0"
              :selection-end="10000"
              :focus="currentCheckIndex == grp[p[0]].id"
              @focus="onCheckFocus(p[0], grp)"
              @input="
                (e) => {
                  let eValue = Number(e.detail.value)
                  grp[p[0]].decimal
                    ? (grp[p[0]].check_value = eValue)
                    : (grp[p[0]].check_value2 = eValue)
                }
              "
              @blur="onBlurCheck(grp[p[0]])"
              @confirm="onCheckConfirm(p[0], grp)"
            />
            <view class="text">复测#{{ index + 1 }}-{{ grp[p[0]].position_id[1] }}</view>
          </view>
        </view>
        <view class="row2 flex-center-between">
          <!-- Number(grp[p[1] - 1].real_value) + Number(grp[p[1] - 1].real_value2) === 0.0 -->
          <view class="left-content" :class="{ active: grp[p[1]].no_pass }">
            <input
              placeholder="请输入"
              :inputmode="currInputMode"
              class="input"
              :disabled="!worktoolStore.deviceId.currDeviceId || users.includes(currentUser[0])"
              :value="grp[p[1]].decimal ? grp[p[1]].real_value : grp[p[1]].real_value2"
              :selection-start="0"
              :selection-end="10000"
              :focus="currentIndex == grp[p[1]].id"
              @focus="onFocus(p[1], grp)"
              @input="
                (e) => {
                  let eValue = Number(e.detail.value)
                  grp[p[1]].decimal
                    ? (grp[p[1]].real_value = eValue)
                    : (grp[p[1]].real_value2 = eValue)
                }
              "
              @blur="onBlur(grp[1])"
              @confirm="onConfirm(p[1], grp)"
            />
            <view class="text">#{{ index + 1 }}-{{ grp[p[1]].position_id[1] }}</view>
          </view>
          <view v-if="checkFlag[index]">
            <input
              placeholder="请输入"
              inputmode="none"
              class="check"
              :disabled="!worktoolStore.deviceId.currDeviceId"
              :value="grp[p[1]].decimal ? grp[p[1]].check_value : grp[p[1]].check_value2"
              :selection-start="0"
              :selection-end="10000"
              :focus="currentCheckIndex == grp[p[1]].id"
              @focus="onCheckFocus(p[1], grp)"
              @input="
                (e) => {
                  let eValue = Number(e.detail.value)
                  grp[p[1]].decimal
                    ? (grp[p[1]].check_value = eValue)
                    : (grp[p[1]].check_value2 = eValue)
                }
              "
              @blur="onBlurCheck(grp[p[1]])"
              @confirm="onCheckConfirm(p[1], grp)"
            />
            <view class="text">复测#{{ index + 1 }}-{{ grp[p[1]].position_id[1] }}</view>
          </view>
          <!-- Number(grp[p[2] - 1].real_value) + Number(grp[p[2] - 1].real_value2) === 0.0 -->
          <view class="right-content" :class="{ active: grp[p[2]].no_pass }">
            <input
              placeholder="请输入"
              :inputmode="currInputMode"
              class="input"
              :disabled="!worktoolStore.deviceId.currDeviceId || users.includes(currentUser[0])"
              :value="grp[p[2]].decimal ? grp[p[2]].real_value : grp[p[2]].real_value2"
              :selection-start="0"
              :selection-end="10000"
              :focus="currentIndex == grp[p[2]].id"
              @focus="onFocus(p[2], grp)"
              @input="
                (e) => {
                  let eValue = Number(e.detail.value)
                  grp[p[2]].decimal
                    ? (grp[p[2]].real_value = eValue)
                    : (grp[p[2]].real_value2 = eValue)
                }
              "
              @blur="onBlur(grp[p[2]])"
              @confirm="onConfirm(p[2], grp)"
            />
            <view class="text">#{{ index + 1 }}-{{ grp[p[2]].position_id[1] }}</view>
          </view>
          <view v-if="checkFlag[index]">
            <input
              placeholder="请输入"
              inputmode="none"
              class="check"
              :disabled="!worktoolStore.deviceId.currDeviceId"
              :value="grp[p[2]].decimal ? grp[p[2]].check_value : grp[p[2]].check_value2"
              :selection-start="0"
              :selection-end="10000"
              :focus="currentCheckIndex == grp[p[2]].id"
              @focus="onCheckFocus(p[2], grp)"
              @input="
                (e) => {
                  let eValue = Number(e.detail.value)
                  grp[p[2]].decimal
                    ? (grp[p[2]].check_value = eValue)
                    : (grp[p[2]].check_value2 = eValue)
                }
              "
              @blur="onBlurCheck(grp[p[2]])"
              @confirm="onCheckConfirm(p[2], grp)"
            />
            <view class="text">复测#{{ index + 1 }}-{{ grp[p[2]].position_id[1] }}</view>
          </view>
        </view>
        <view class="row3 flex-center-between">
          <!-- Number(grp[p[3] - 1].real_value) + Number(grp[p[3] - 1].real_value2) === 0.0 -->
          <view class="left-content" :class="{ active: grp[p[3]].no_pass }">
            <input
              placeholder="请输入"
              :inputmode="currInputMode"
              class="input"
              :disabled="!worktoolStore.deviceId.currDeviceId || users.includes(currentUser[0])"
              :value="grp[p[3]].decimal ? grp[p[3]].real_value : grp[p[3]].real_value2"
              :selection-start="0"
              :selection-end="10000"
              :focus="currentIndex == grp[p[3]].id"
              @focus="onFocus(p[3], grp)"
              @input="
                (e) => {
                  let eValue = Number(e.detail.value)
                  grp[p[3]].decimal
                    ? (grp[p[3]].real_value = eValue)
                    : (grp[p[3]].real_value2 = eValue)
                }
              "
              @blur="onBlur(grp[p[3]])"
              @confirm="onConfirm(p[3], grp)"
            />
            <view class="text">#{{ index + 1 }}-{{ grp[p[3]].position_id[1] }}</view>
          </view>
          <view v-if="checkFlag[index]">
            <input
              placeholder="请输入"
              inputmode="none"
              class="check"
              :disabled="!worktoolStore.deviceId.currDeviceId"
              :value="grp[p[3]].decimal ? grp[p[3]].check_value : grp[p[3]].check_value2"
              :selection-start="0"
              :selection-end="10000"
              :focus="currentCheckIndex == grp[p[3]].id"
              @focus="onCheckFocus(p[3], grp)"
              @input="
                (e) => {
                  let eValue = Number(e.detail.value)
                  grp[p[3]].decimal
                    ? (grp[p[3]].check_value = eValue)
                    : (grp[p[3]].check_value2 = eValue)
                }
              "
              @blur="onBlurCheck(grp[p[3]])"
              @confirm="onCheckConfirm(p[3], grp)"
            />
            <view class="text">复测#{{ index + 1 }}-{{ grp[p[3]].position_id[1] }}</view>
          </view>
          <!-- Number(grp[p[4] - 1].real_value) + Number(grp[p[4] - 1].real_value2) === 0.0 -->
          <view class="right-content" :class="{ active: grp[p[4]].no_pass }">
            <input
              placeholder="请输入"
              :inputmode="currInputMode"
              class="input"
              :disabled="!worktoolStore.deviceId.currDeviceId || users.includes(currentUser[0])"
              :value="grp[p[4]].decimal ? grp[p[4]].real_value : grp[p[4]].real_value2"
              :selection-start="0"
              :selection-end="10000"
              :focus="currentIndex == grp[p[4]].id"
              @focus="onFocus(p[4], grp)"
              @input="
                (e) => {
                  let eValue = Number(e.detail.value)
                  grp[p[4]].decimal
                    ? (grp[p[4]].real_value = eValue)
                    : (grp[p[4]].real_value2 = eValue)
                }
              "
              @blur="onBlur(grp[p[4]])"
              @confirm="onConfirm(p[4], grp)"
            />
            <view class="text">#{{ index + 1 }}-{{ grp[p[4]].position_id[1] }}</view>
          </view>
          <view v-if="checkFlag[index]">
            <input
              placeholder="请输入"
              inputmode="none"
              class="check"
              :disabled="!worktoolStore.deviceId.currDeviceId"
              :value="grp[p[4]].decimal ? grp[p[4]].check_value : grp[p[4]].check_value2"
              :selection-start="0"
              :selection-end="10000"
              :focus="currentCheckIndex == grp[p[4]].id"
              @focus="onCheckFocus(p[4], grp)"
              @input="
                (e) => {
                  let eValue = Number(e.detail.value)
                  grp[p[4]].decimal
                    ? (grp[p[4]].check_value = eValue)
                    : (grp[p[4]].check_value2 = eValue)
                }
              "
              @blur="onBlurCheck(grp[p[4]])"
              @confirm="onCheckConfirm(p[4], grp)"
            />
            <view class="text">复测#{{ index + 1 }}-{{ grp[p[4]].position_id[1] }}</view>
          </view>
        </view>
        <!-- Number(grp[p[5] - 1].real_value) + Number(grp[p[5] - 1].real_value2) === 0.0 -->
        <view class="row4 flex-center">
          <view class="content" :class="{ active: grp[p[5]].no_pass }">
            <input
              placeholder="请输入"
              :inputmode="currInputMode"
              class="input"
              :disabled="!worktoolStore.deviceId.currDeviceId || users.includes(currentUser[0])"
              :value="grp[p[5]].decimal ? grp[p[5]].real_value : grp[p[5]].real_value2"
              :selection-start="0"
              :selection-end="10000"
              :focus="currentIndex == grp[p[5]].id"
              @focus="onFocus(p[5], grp)"
              @input="
                (e) => {
                  let eValue = Number(e.detail.value)
                  grp[p[5]].decimal
                    ? (grp[p[5]].real_value = eValue)
                    : (grp[p[5]].real_value2 = eValue)
                }
              "
              @blur="onBlur(grp[p[5]])"
              @confirm="onConfirm(p[5], grp)"
            />
            <view class="text">#{{ index + 1 }}-{{ grp[p[5]].position_id[1] }}</view>
          </view>
          <view v-if="checkFlag[index]">
            <input
              placeholder="请输入"
              inputmode="none"
              class="check"
              :disabled="!worktoolStore.deviceId.currDeviceId"
              :value="grp[p[5]].decimal ? grp[p[5]].check_value : grp[p[5]].check_value2"
              :selection-start="0"
              :selection-end="10000"
              :focus="currentCheckIndex == grp[p[5]].id"
              @focus="onCheckFocus(p[5], grp)"
              @input="
                (e) => {
                  let eValue = Number(e.detail.value)
                  grp[p[5]].decimal
                    ? (grp[p[5]].check_value = eValue)
                    : (grp[p[5]].check_value2 = eValue)
                }
              "
              @blur="onBlurCheck(grp[p[5]])"
              @confirm="onCheckConfirm(p[5], grp)"
            />
            <view class="text">复测#{{ index + 1 }}-{{ grp[p[5]].position_id[1] }}</view>
          </view>
        </view>
      </view>
    </template>
  </view>
</template>

<script setup>
import { onShow } from '@dcloudio/uni-app'
import { ref, onMounted, onUnmounted, computed } from 'vue'
import { useWorkmainStore, useWorksubStore, useWorktoolStore, useUserStore } from '@/stores'
import { dateShow } from '@/utils/utils.js'
import { emitter } from '@/EventBus'

const workMain = useWorkmainStore()
const worksubStore = useWorksubStore()
const userStore = useUserStore()
const worktoolStore = useWorktoolStore()

//旋转方向时的索引
const currentIndex = ref(0)
//旋转方向时的复测的索引
const currentCheckIndex = ref(0)

//顺时针input顺序(从上到下，从左到右的顺序)对应的数据
const pcw = ref([0, 5, 1, 4, 2, 3])
//逆时针input顺序对应的数据
const pccw = ref([0, 1, 5, 2, 4, 3])
//最终的旋转数组，在show中根据数据设定
const p = ref({})
function onConfirm(q, grp) {
  // setTimeout(() => {
  if (grp[q + 1] === undefined) {
    currentIndex.value = grp[0].id
  } else {
    currentIndex.value = grp[q + 1].id
  }
  // }, 0)
}
function onCheckConfirm(q, grp) {
  // setTimeout(() => {
  if (grp[q + 1] === undefined) {
    currentCheckIndex.value = grp[0].id
  } else {
    currentCheckIndex.value = grp[q + 1].id
  }
  // }, 0)
}

const workMainId = ref()
// 当前work-main数据
const workMainData = ref({})
// worksub数据
const worksubData = ref()
//当前使用的设备
// const deviceId = ref({})
// deviceId.value = worktoolStore.deviceId
//可放行的用户
const users = ref([])
//当前用户
const currentUser = ref([])
const focusItem = ref({})
function onFocus(q, grp) {
  //如果点击的不是复测框，需要将focusCheckItem.value[0]设置为false
  focusCheckItem.value[0] = false
  currentIndex.value = grp[q].id
  focusItem.value[0] = q
  focusItem.value[1] = grp

  // console.log(focusItem.value)
}
//选中复测
const checkFlag = ref({})
function onCheck(index) {
  if (workMainData.value.key) {
    checkFlag.value[index] = !checkFlag.value[index]
    console.log(checkFlag.value)
  }
}
//聚焦在check_value
const focusCheckItem = ref([])
//将worksub按6条记录分一组
const groupWorksubData = ref([])
function onCheckFocus(q, grp) {
  //设置数组0：为点击的是复测框，1：为点击的item
  currentCheckIndex.value = grp[q].id
  focusCheckItem.value[0] = true
  focusCheckItem.value[1] = q
  focusCheckItem.value[2] = grp
}
function onBlurCheck(item) {
  let check_val = Number(item.check_value)
  let check_val2 = Number(item.check_value2)
  item.decimal
    ? (item.check_value = check_val.toFixed(3))
    : (item.check_value2 = check_val2.toFixed(2))
  // item.datetime_work = dateShow()[0]
  // item.datetimeUTC = dateShow()[1]
  // item.operator_id = currentUser.value[0]
  item.deviceId = worktoolStore.deviceId.currDeviceId
  // if (item.decimal) {
  //   if (item.real_value < item.min_value || item.real_value > item.max_value) {
  //     item.no_pass = true
  //   } else {
  //     item.no_pass = false
  //   }
  // } else {
  //   if (item.real_value2 < item.min_value2 || item.real_value2 > item.max_value2) {
  //     item.no_pass = true
  //   } else {
  //     item.no_pass = false
  //   }
  // }
  // updateMainNopass()
}
function onBlur(item) {
  let real_val = Number(item.real_value)
  let real_val2 = Number(item.real_value2)
  item.decimal ? (item.real_value = real_val.toFixed(3)) : (item.real_value2 = real_val2.toFixed(2))
  item.datetime_work = dateShow()[0]
  item.datetimeUTC = dateShow()[1]
  item.operator_id = currentUser.value[0]
  item.deviceId = worktoolStore.deviceId.currDeviceId
  if (item.decimal) {
    if (item.real_value < item.min_value || item.real_value > item.max_value) {
      item.no_pass = true
    } else {
      item.no_pass = false
    }
  } else {
    if (item.real_value2 < item.min_value2 || item.real_value2 > item.max_value2) {
      item.no_pass = true
    } else {
      item.no_pass = false
    }
  }
  //updateMainNopass()
}
//worksub.no_pass 更新workmain.no_pass,以便判断是否操作完，并且符合数据范围，可以上传
function updateMainNopass() {
  // console.log(workMainData.value)
  workMainData.value.no_pass = !worksubData.value.every((element) => {
    return !element.no_pass
  })
  // console.log(workMainData.value.no_pass)
}
//选中蓝牙后，进行创建连接并采集数据

//input组件inputmode，判断是否跳出软键盘
const currInputMode = computed(() => {
  if (!worktoolStore.notBluedev) {
    console.log('none')
    return 'none'
  } else {
    console.log('decimal')
    return 'decimal'
  }
})
//选中蓝牙后，进行创建连接并采集数据
function onClickBlue(item) {
  clickBlue(item, processBleData)
}
function onSendData() {
  // sendData(processBleData, currentIndex.value, currInputMode.value, currentCheckIndex.value)
  emitter.emit('sendData', [currentIndex.value, currInputMode.value, currentCheckIndex.value])
}
//下面是采集数据后的处理，需要根据当前具体组件的内容重写
function processBleData(getValue) {
  let value = getValue[0]
  let unit = getValue[1]
  console.log(focusCheckItem.value)
  //当点击不是复测框时
  if (!focusCheckItem.value[0]) {
    let q = focusItem.value[0]
    let grp = focusItem.value[1]
    if (grp[q].decimal) {
      grp[q].real_value = value.toFixed(3)
      // console.log('real_value', focusItem.value.real_value)
    } else {
      grp[q].real_value2 = value.toFixed(2)
      // console.log('real_value2', focusItem.value.real_value2)
    }
    grp[q].datetime_work = dateShow()[0]
    grp[q].datetimeUTC = dateShow()[1]
    grp[q].operator_id = currentUser.value[0]
    grp[q].deviceId = worktoolStore.deviceId.currDeviceId
    if (grp[q].decimal) {
      if (grp[q].real_value < grp[q].min_value || grp[q].real_value > grp[q].max_value) {
        grp[q].no_pass = true
      } else {
        grp[q].no_pass = false
      }
    } else {
      if (grp[q].real_value2 < grp[q].min_value2 || grp[q].real_value2 > grp[q].max_value2) {
        grp[q].no_pass = true
      } else {
        grp[q].no_pass = false
      }
    }
    // updateMainNopass()
    onConfirm(q, grp)
    //当点击是复测框时
  } else {
    let q = focusCheckItem.value[1]
    let grp = focusCheckItem.value[2]
    if (grp[q].decimal) {
      grp[q].check_value = value.toFixed(3)
    } else {
      grp[q].check_value2 = value.toFixed(2)
    }
    console.log(grp[q].check_value, grp[q].check_value2)
    onCheckConfirm(q, grp)
    // console.log(focusCheckItem.value)
    // //当点击不是复测框时
    // if (!focusCheckItem.value[0]) {
    //   if (focusItem.value.decimal) {
    //     focusItem.value.real_value = value.toFixed(3)
    //     // console.log('real_value', focusItem.value.real_value)
    //   } else {
    //     focusItem.value.real_value2 = value.toFixed(2)
    //     // console.log('real_value2', focusItem.value.real_value2)
    //   }
    //   focusItem.value.datetime_work = dateShow()[0]
    //   focusItem.value.datetimeUTC = dateShow()[1]
    //   focusItem.value.operator_id = currentUser.value[0]
    //   focusItem.value.deviceId = deviceId.value.currDeviceId
    //   if (focusItem.value.decimal) {
    //     if (
    //       focusItem.value.real_value < focusItem.value.min_value ||
    //       focusItem.value.real_value > focusItem.value.max_value
    //     ) {
    //       focusItem.value.no_pass = true
    //     } else {
    //       focusItem.value.no_pass = false
    //     }
    //   } else {
    //     if (
    //       focusItem.value.real_value2 < focusItem.value.min_value2 ||
    //       focusItem.value.real_value2 > focusItem.value.max_value2
    //     ) {
    //       focusItem.value.no_pass = true
    //     } else {
    //       focusItem.value.no_pass = false
    //     }
    //   }
    //   updateMainNopass()
    //   //当点击是复测框时
    // } else {
    //   if (focusCheckItem.value[1].decimal) {
    //     focusCheckItem.value[1].check_value = value.toFixed(3)
    //   } else {
    //     focusCheckItem.value[1].check_value2 = value.toFixed(2)
    //   }
    //   console.log(focusCheckItem.value[1].check_value, focusCheckItem.value[1].check_value2)
    // }
  }
}
// onShow(async () => {
//   currentUser.value = [userStore.userInfo.uid, userStore.userInfo.name]
//   // console.log(currentUser.value)
//   // //获取可放行用户
//   users.value = userStore.userInfo.users
//   // console.log(users.value)
//   //货期worksubData
//   workMainId.value = worksubStore.currentWorkMainId
//   worksubData.value = worksubStore.records[workMainId.value]
//   // console.log(worksubData.value)
//   //获取workMainData
//   const workMainIndex = workMain.records.findIndex((item) => item.id == workMainId.value)
//   workMainData.value = workMain.records[workMainIndex]
//   // deviceId.value = worktoolStore.deviceId
//   groupWorksubData.value = []

//   for (let i = 0; i < worksubData.value?.length; i += 6) {
//     groupWorksubData.value.push(worksubData.value.slice(i, i + 6))
//   }
//   console.log(groupWorksubData.value)
//   // console.log(groupWorksubData.value[0][0])

//   currentIndex.value = groupWorksubData.value[0][0].id
//   currentCheckIndex.value = groupWorksubData.value[0][0].id

//   if (workMainData.value.direction === 'CW') {
//     p.value = pcw.value
//   } else if (workMainData.value.direction === 'CCW') {
//     p.value = pccw.value
//   }
//   // console.log(workMainData.value.direction)
//   // console.log(p.value)
// })
onMounted(async () => {
  //接收WorkHead发出的事件
  // emitter.on('onClickBlue', onClickBlue)
  emitter.on('process', processBleData)
  emitter.on('onSendData', onSendData)
  currentUser.value = [userStore.userInfo.uid, userStore.userInfo.name]
  // console.log(currentUser.value)
  //获取可放行用户
  users.value = userStore.userInfo.users
  // console.log(users.value)
  //货期worksubData
  workMainId.value = worksubStore.currentWorkMainId
  worksubData.value = worksubStore.records[workMainId.value]
  // console.log(worksubData.value)
  //获取workMainData
  const workMainIndex = workMain.records.findIndex((item) => item.id == workMainId.value)
  workMainData.value = workMain.records[workMainIndex]
  // deviceId.value = worktoolStore.deviceId
  groupWorksubData.value = []
  // console.log(worksubData.value.length)

  for (let i = 0; i < worksubData.value?.length; i += 6) {
    groupWorksubData.value.push(worksubData.value.slice(i, i + 6))
  }
  console.log(groupWorksubData.value)

  currentIndex.value = groupWorksubData.value[0][0].id
  currentCheckIndex.value = groupWorksubData.value[0][0].id
  if (workMainData.value.direction === 'CW') {
    p.value = pcw.value
  } else if (workMainData.value.direction === 'CCW') {
    p.value = pccw.value
  }
  console.log(workMainData.value.direction)
  console.log(p.value)
})
onUnmounted(() => {
  //关闭WorkHead所发出的事件
  // emitter.off('onClickBlue', onClickBlue)
  emitter.off('process')
  emitter.off('onSendData')
  updateMainNopass()
})
</script>
<style lang="scss" scoped>
.work-page {
  .margin-top-bottom {
    margin: 10px 0;
  }
  // .temperature {
  //   display: flex;
  //   flex-direction: row;
  //   justify-content: center;
  //   width: 100%;
  //   .text {
  //     font-size: 12px;
  //     font-weight: 700;
  //     color: blueviolet;
  //     width: 70px;
  //   }
  //   .input {
  //     width: 30px;
  //   }
  // }
  .temperature {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center; // 添加垂直居中
    flex-wrap: wrap; // 允许换行
    width: 100%;
    gap: 10px; // 添加间距
    padding: 10px 0; // 添加上下内边距

    .text {
      font-size: 12px; // 增大字体
      font-weight: 700;
      color: blueviolet;
      white-space: nowrap; // 防止文字换行
    }

    .input {
      width: 50px; // 增加输入框宽度

      input {
        width: 100%;
        height: 36px;
        border: 1px solid #dcdfe6;
        border-radius: 4px;
        padding: 0 8px;
        box-sizing: border-box;
        background-color: #fff;

        &:focus {
          border-color: #1598fa;
          outline: none;
        }
      }
    }
  }
  .table {
    .input {
      width: 70px;
      height: 40px;
      text-align: center;
      // background-color: $uni-text-color-disable;
      background-color: #e0e0e0;
      background-color: $text-font-color-4;
      border-radius: 15%;
      // border: 1px solid #000;
    }
    .check {
      width: 70px;
      height: 40px;
      text-align: center;
      // background-color: $uni-text-color-disable;
      background-color: #e0ffff;
      // background-color: $text-font-color-4;
      border-radius: 15%;
      // border: 1px solid #000;
    }
    .active {
      color: #e64340;
    }
    .text {
      font-size: 12px;
      text-align: center;
      color: $text-font-color-2;
    }
    .grp {
      display: flex;
      flex-direction: row;
      justify-content: center;
      font-weight: 700;
      color: $brand-theme-color;
    }
    .nkey {
      display: flex;
      flex-direction: row;
      justify-content: center;
      font-weight: 700;
      //4号模板不需要复测，所以不设置下面颜色
      // color: $brand-theme-color;
    }
  }
}
</style>
